package TEst;

/**
 * @author 李某
 * * @date 2021/11/19
 * *物有本末，事有终始。知其先后者，则近道矣！
 * *荷花开满池塘的前一天还是半塘荷花半塘云。
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/LifeTimeTest")
//替代了 XML 文件
public class LifeTimeTest extends HttpServlet {



    public void init(){
        System.out.println("初始化进行中~~~");
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("拆分后的 servlet 方法 —— doGet");
        for (int i = 0; i <= 100; i++) {
            try {
                Thread.sleep(10*100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (i == 1){
                System.out.println("线程开始");
            }else if (i == 5){
                System.out.println("线程中");
            }else if(i == 50){
                System.out.println("线程结束");
            }

            System.out.println(i);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("拆分后的 servlet 方法 —— doPost");
    }

    public void destroy(){
        System.out.println("销毁方法！！！！");
    }


}
